'''
Created on 4/03/2013

@author: Jorge
'''
from DatasetTransformation import DatasetTransformation
import numpy as np
from sklearn import preprocessing

class NormalizeData(DatasetTransformation):
    '''
    classdocs
    '''

    def transformation(self, X):
        """ n = len(X[0])
        m = len(X)
        mean=[0]*n
        standar_desviation=[0]*n
        for i in xrange(n):
            column_i = [ d[i] for d in X ]
            mean[i]=np.average(column_i)
            standar_desviation[i]=np.std(column_i)

        for i in range(m):
            for j in range(n):
                #print mean[j], standar_desviation[j] 
                X[i][j]= (X[i][j]-mean[j])/standar_desviation[j]
                if np.math.isnan( X[i][j]):
                    X[i][j]=0"""
        X = preprocessing.scale(X)
        
        return X
        